const vm = new Vue({
    el: '#main',
    data: {
        authCodeText: '获取验证码',
        tel: '',
        code: '',
        pwd: '',
        confirmPwd: '',
        reqCode: true,
    },
    methods: {
        countDown,
    },
});

function apiready() {
    main();
}

function main() {
    fxj.fixLayout();
    fxj.api.getOldPhone().then(
        ([data, ok]) => {
            if (ok) {
                vm.tel = data;
            }
            else {
                toast(data);
            }
        },
    );
}


function countDown() {
    fxj.api.getAuthCodeBtn(document.getElementById('getAuthCode'), vm.tel);
}

function submit() {
    if (vm.pwd !== vm.confirmPwd) {
        mui.toast('两次密码不一致');
        return;
    }
    ajax({
        type: 'POST',
        url: 'home/userLogin/modifyPwd',
        data: {
            phone: vm.tel,
            code: vm.code,
            pwd: vm.pwd,
        },
    }).then(
        result => {
            mui.toast(result.msg);
            if (result.err === 0) {
                fxj.closeWin();
            }
        },
    );
}